<!DOCTYPE html>
<html lang="zh">
<head>
    <title>{{ title }}</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=0.4">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <script src="/static/js/jquery-v3.6.0.min.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link rel="shortcut icon" href="/static/public/favicon.ico">
</head>
<body class="layui-bg-gray">

<br><br><br>
<div class="layui-container" style="text-align: center;">
    <div class="layui-row">
        <h2>{{ title }}</h2>
        <br><br>

        <form class="layui-form">
            {{ csrf_field }}
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">账&nbsp;&nbsp;户</label>
                    <div class="layui-input-inline">
                        <input type="text" name="account" lay-verify="required" autocomplete="off" maxlength="15" placeholder="请输入账户" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">密&nbsp;&nbsp;码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" lay-verify="required" maxlength="20" placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

<!--            <div class="layui-form-item">-->
<!--                <div class="layui-inline">-->
<!--                    <label class="layui-form-label">验证码</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" name="captcha" lay-verify="required" maxlength="10" placeholder="请输入验证码" autocomplete="off" class="layui-input">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">登录</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">
                        <a href="/admin/index" class="layui-btn layui-btn-lg layui-btn-primary">
                            <i class="layui-icon layui-icon-home"></i>
                        </a>
                    </label>
                    <div class="layui-input-inline"></div>
                </div>
            </div>
        </form>
    </div>
</div>

</body>

<script>
    //Demo
    layui.use(['form', 'laydate'], function(){
        var form = layui.form;
        // form.render('select');

        //监听提交
        form.on('submit(formDemo)', function(data){
            //当前容器的全部表单字段，名值对形式：{name: value}
            console.log(data);
            // layer.msg(JSON.stringify(data.field));
            let url = "{{ uri }}/login"
            $.ajax({
                url: url,
                method: "post",
                data: data.field,
                dataType: "JSON",
                success: function (callback){
                    console.log(callback);
                    layer.msg(callback.message);

                    if (callback.code === 1)
                    {
                        setTimeout(function(){
                            location.href = "/admin/index";
                        }, 1000);
                    }
                }
            });

            return false;
        });
    });
</script>

</html>